<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Profile</title>

<link href="/assets/css/bootstrap.css" rel="stylesheet">
<link href="/assets/css/datepicker3.css" rel="stylesheet">
<link href="/assets/css/styles.css" rel="stylesheet">

<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->

</head>

<body>
	<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar-collapse">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="/"><span>Motion</span>Global</a>
				<ul class="user-menu">
					<li class="dropdown pull-right">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span><?php echo $data['user_name'];?><span class="caret"></span></a>
						<ul class="dropdown-menu" role="menu">
							<li><a href="/user/profile"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
							<li><a href="#"><span class="glyphicon glyphicon-cog"></span> Settings</a></li>
							<li><a href="#"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
						</ul>
					</li>
				</ul>
			</div>
							
		</div><!-- /.container-fluid -->
	</nav>
	<?php $this->load->view("/widgets/left_nav");?>
		
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
		<div class="row">
			<ol class="breadcrumb">
				<li><a href="#"><span class="glyphicon glyphicon-home"></span></a></li>
				<li class="">Profile</li>
			</ol>
		</div><!--/.row-->
		
		<div class="row">
			<div class="col-lg-12">
				<h1 class="page-header">Basic Information</h1>
			</div>
		</div><!--/.row-->
				
		
		<div class="row">
			<div class="col-mg-12">
				<div class="panel panel-default">
					<div class="panel-heading"></div>
					<div class="panel-body">
						<div class="col-md-6">
							<form role="form">
							
								

								<div class="panel panel-default">
								  <div class="panel-heading">Your Name</div>
								  <div class="panel-body" id="name_panel">
								    <?php echo $data['user_name'];?>
								  </div>
								</div>
																
								<div class="panel panel-default">
								  <div class="panel-heading">Your Title</div>
								  <div class="panel-body" id="title_panel">
								    <?php echo $data['title'];?>
								  </div>
								</div>

								<div class="panel panel-default">
								  <div class="panel-heading">Your Department</div>
								  <div class="panel-body" id="depa_panel">
								    <?php echo $data['department'];?>
								  </div>
								</div>
								
								<button type="button" class="btn btn-success">Edit</button>  
								<button type="button" class="btn btn-primary">Save</button>
							</form>
						</div>
						<div class = "col-md-6">
							<div class="panel panel-default">
								  <div class="panel-heading">Leave Days Left</div>
								  <div class="panel-body" id="">
								    <?php echo $data['leave_days'];?>
								  </div>
								</div>

								<div class="panel panel-default">
								  <div class="panel-heading">Sick Leave Days Left</div>
								  <div class="panel-body" id="">
								    <?php echo $data['sick_days'];?>
								  </div>
								</div>
						</div>
				</div>
			</div><!-- /.col-->
		</div><!-- /.row -->
		
	</div><!--/.main-->

	<script src=" /assets/js/jquery-1.11.1.min.js"></script>
	<script src=" /assets/js/bootstrap.min.js"></script>
	<script src=" /assets/js/chart.min.js"></script>
	<script src=" /assets/js/chart-data.js"></script>
	<script src=" /assets/js/easypiechart.js"></script>
	<script src=" /assets/js/easypiechart-data.js"></script>
	<script src=" /assets/js/bootstrap-datepicker.js"></script>
	<script>
		!function ($) {
			$(document).on("click","ul.nav li.parent > a > span.icon", function(){		  
				$(this).find('em:first').toggleClass("glyphicon-minus");	  
			}); 
			$(".sidebar span.icon").find('em:first').addClass("glyphicon-plus");
		}(window.jQuery);

		$(window).on('resize', function () {
		  if ($(window).width() > 768) $('#sidebar-collapse').collapse('show')
		})
		$(window).on('resize', function () {
		  if ($(window).width() <= 767) $('#sidebar-collapse').collapse('hide')
		})


		$(".btn-success").click(function()
		{
			$("#name_panel").empty();
			$("#title_panel").empty();
			$("#depa_panel").empty();
			$("#name_panel").append('<input class="form-control" id="name_input" value="<?php echo $data['user_name'];?>">');
			$("#title_panel").append('<input class="form-control" id="title_input" value="<?php echo $data['title'];?>">');
			$("#depa_panel").append('<input class="form-control" id="depa_input" value="<?php echo $data['department'];?>">');
			$(".btn-primary").attr("onclick","post_to()");
		});

		function post_to()
		{
			$.post("/user/edit/profile",
			{
				user_name : $("#name_input").val(),
				title: $("#title_input").val(),
				department: $("#depa_input").val()
			},
			function(data,status)
			{
				json1 = eval("("+data+")");
				if(json1.code == "200")
				{
					confirm("Your profile has been updated");
					location.href= '/user/profile';
				}
			});
		}
	</script>	
</body>

</html>
